/*
 * global.java
 *
 * Created on March 10, 2006, 7:00 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

/**
 *
 * @author Sujal Bista
 */

import javax.swing.JComboBox;
import java.util.Vector;

public class globalData
{
    //sets whether judging type is tradional or nandu
    //first 3 for judge A
    //second 3 for judge B
    //last 3 for judge C
    public static int scoringSystem;
    
    //type of judge A,B,C ony used for nonTraditional system
    //A=1, B=2, C=3 
    //judgetType is changed when traditionalScoringSystem changes while
    //this one doesnt'
    //used as backup when switching back
    public static int defaultJudgeType;
    //type of judge A,B,C ony used for nonTraditional system
    //A=1, B=2, C=3
    public static int judgeType;
    
    //tracking if any athlete is currently active
    public static boolean athleteActive;
    public static athlete currentAthlete;
    
    public static int numButtonPressed;
    public static Vector nanduResults;
    
    public static nanduData nanduList;
    
    //pointer to the objects used by threads
    public static javax.swing.JLabel CaptionInput;
    public static javax.swing.JTextField BoxInput;
    public static javax.swing.JButton ButtonInput1;
    public static javax.swing.JButton ButtonInput2;
    public static javax.swing.JButton ButtonInput3;
    public static javax.swing.JButton ButtonInput4;
    public static javax.swing.JTextArea TextArea;
    
    
    public static void initGlobalData()
    {
        scoringSystem=0;  //turn this on to enable traditional judging
        judgeType=2;    //judge B 
        athleteActive=false;
        currentAthlete=new athlete();
        numButtonPressed=0;
        nanduList=new nanduData();
        nanduResults=new Vector();
        
    }
    
    //converts judges number to appopriate type
    public static int judgeNumberToJudgeType(int judgeNum)
    {
        if(globalData.scoringSystem==0)
            return 2;   //judge b
        else if(globalData.scoringSystem==1)
        {
            if(judgeNum==0 || judgeNum==3 || judgeNum==6 || judgeNum==2 || judgeNum==5)
                return 1;   //judge a
            else
                return 2;   //judge b
        }
        return judgeNum%3+1;    //judge a,b,c alternate
    }
    
    //sets up screen based of type of judges
    public static void setScreen()
    {
        switch(judgeType)
        {
            case 1: //judge A
            {
                //set the visible status
                TextArea.setVisible(true);
                ButtonInput1.setVisible(true);
                ButtonInput2.setVisible(true);
                CaptionInput.setVisible(true);
                BoxInput.setVisible(true);
                ButtonInput3.setVisible(true);
                ButtonInput4.setVisible(true);
                
                BoxInput.setEnabled(true);
                ButtonInput1.setEnabled(true);
                ButtonInput2.setEnabled(false);
                CaptionInput.setEnabled(true);
                ButtonInput3.setEnabled(true);
                ButtonInput4.setEnabled(false);
                

                //set appropriate captions
                TextArea.setText("Judge A Waiting for Head Judge\n");
                TextArea.append("To Start\n");
                ButtonInput1.setText("Mistake");
                ButtonInput2.setText("Cancel");
                CaptionInput.setText("Enter Codes Into Box Below");
                BoxInput.setText("");
                ButtonInput3.setText("Submit");
                ButtonInput4.setText("Undo");
                
                numButtonPressed=0;
                
                //grab focus
                ButtonInput1.grabFocus();
                break;
            }
            case 2: //judge B
            {
                //set the visible status
                TextArea.setVisible(true);
                ButtonInput1.setVisible(false);
                ButtonInput2.setVisible(false);
                CaptionInput.setVisible(true);
                BoxInput.setVisible(true);
                ButtonInput3.setVisible(true);
                ButtonInput4.setVisible(true);
                
                BoxInput.setEnabled(true);
                ButtonInput1.setEnabled(false);
                ButtonInput2.setEnabled(false);
                CaptionInput.setEnabled(true);
                ButtonInput3.setEnabled(true);
                ButtonInput4.setEnabled(false);
                                

                //set appropriate captions
                TextArea.setText("Judge B Waiting for Head Judge\n");
                TextArea.append("To Start\n");
                ButtonInput1.setText("");
                ButtonInput2.setText("");
                CaptionInput.setText("Enter Score Into Box Below");
                BoxInput.setText("");
                ButtonInput3.setText("Submit");
                ButtonInput4.setText("Undo");

                //grab focus
                CaptionInput.grabFocus();
            
                break;
            }
            case 3: //judge C
            {
                //set the visible status
                TextArea.setVisible(true);
                ButtonInput1.setVisible(true);
                ButtonInput2.setVisible(true);
                CaptionInput.setVisible(false);
                BoxInput.setVisible(false);
                ButtonInput3.setVisible(true);
                ButtonInput4.setVisible(false);
                
                BoxInput.setEnabled(true);
                ButtonInput1.setEnabled(true);
                ButtonInput2.setEnabled(true);
                CaptionInput.setEnabled(false);
                ButtonInput3.setEnabled(false);
                ButtonInput4.setEnabled(false);
                

                //set appropriate captions
                TextArea.setText("Judge C Waiting for Head Judge\n");
                TextArea.append("To Start\n");
                ButtonInput1.setText("Success");
                ButtonInput2.setText("Fail");
                CaptionInput.setText("");
                BoxInput.setText("");
                ButtonInput3.setText("Undo");
                ButtonInput4.setText("");

                //grab focus
                ButtonInput1.grabFocus();
                break;
            }
        }
    }
    
   
}
